package com.powerbosframework.web.util;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

import com.powerbosframework.web.action.GlobalMessage;

public class RequestURI {
	public static String ISO_ENCODING="iso-8859-1";
	public static String CONTEXT_ENCODING="utf-8";
	/**
	 * 得到编码的字符串
	 * @param s
	 * @return
	 */
	public static String getURLEncode(String s) {
		if (s==null) return "";
		try {
			s = URLEncoder.encode(s,CONTEXT_ENCODING);
		} catch (UnsupportedEncodingException e) {			
			e.printStackTrace();
		}
		return s;
	}
	/**
	 * 返回GET编码字符串
	 * @param str
	 * @return
	 */
	public static String getGetEncode(String str){
		if(str==null||"".equals(str.equals(""))) return str;
		try {
			str=new String(str.getBytes(CONTEXT_ENCODING));
		} catch (UnsupportedEncodingException e) {			
			e.printStackTrace();
		}
		return str;
	}
	/**
	 * 返回POST编码字符串
	 * @param str
	 * @return
	 */
	public static String getPostEncode(String str){
		if(str==null||"".equals(str.equals(""))) return str;
		try {
			str=new String(str.getBytes(ISO_ENCODING),CONTEXT_ENCODING);
		} catch (UnsupportedEncodingException e) {			
			e.printStackTrace();
		}
		return str;
	}
	
}
